import type { NextRequest } from 'next/server';
import { requirementClient } from "@/grpc";
import { project_requirement_api } from "@/proto_gen_ts/proto/project_requirement_api";

export async function GET(request: NextRequest): Promise<Response> {
    const params = request.nextUrl.searchParams;
    const id = params.get("id") ?? "";
    const secret = params.get("secret") ?? "";

    return new Promise((resolve, reject) => {
        requirementClient.getKanoInfoByShare(new project_requirement_api.GetKanoInfoByShareRequest({ shareId: id, shareSecret: secret }),
            (error, response) => {
                if (error) {
                    reject(error);
                } else {
                    resolve(Response.json(response?.toObject()));
                }
            }
        );
    });
}